package com.quanjiaolian.userinfo.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.quanjiaolian.tools.ResponseToJson;
import com.quanjiaolian.userinfo.service.MsgCenterService;
import com.quanjiaolian.userinfo.serviceimpl.MsgCenterServiceImpl;

/**
 * 更新未读消息状态
 * @author Heraon-Li
 *
 */
@SuppressWarnings("serial")
public class UpdateMsgState extends HttpServlet {
	
	/**
	 * 声明Log4j变量
	 */
	public static ResourceBundle resourceBundle = null;
	static Logger logger = Logger.getLogger(UpdateMsgState.class.getName());
	MsgCenterService ms = new MsgCenterServiceImpl(); 
	Map<String,Object> resultMap = new HashMap<String,Object>();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try{
			String re_id = request.getParameter("re_id");
			int i = ms.updateMsgState(Integer.parseInt(re_id));
			if(i>0){
				resultMap.put("result","OK");
			}else{
				resultMap.put("result","Failed");
			}
		}catch (Exception e) {
			resultMap.put("result","Error");
			logger.info(e);
		}
		
		ResponseToJson.responseOutWithJson(response,resultMap);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doGet(request, response);
	}

}
